#include <REGX52.H>
#include <INTRINS.H>
void Delay1ms(int xms)		//@12.000MHz
{
	unsigned char i, j;
	while(xms--){
		i = 12;
	j = 169;
	do
	{
		while (--j);
	} while (--i);
	}
}
unsigned int s=1,m=5;
void main(){
	
	P2=(P2&0x1f)|0x80;
	while(1){
		if(P3_1==0){
			Delay1ms(20);
			while(P3_1==0);
			Delay1ms(20);
			if(s==256){
				s=1;
				m=5;
			}
			P0=255;
			P0=P0-s;
			s=s*2;
		}
		if(P3_0==0){
			Delay1ms(20);
			while(P3_0==0);
			Delay1ms(20);
			m=s/2;
			s=s/2;
			P0=P0+m-s/2;
	}
		if(s>128)
			s=1;
		if(m==1){
			s=128*2;
			P0=127;
		}
	}
}